﻿Public Class frmThongKe

    Dim _ThongKe As New ThongKe

    Private Sub frmThongKe_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ThongKe(_ThongKe)
        dgvBanDuocTheoThang.Columns(0).HeaderText = "Tên sản phẩm"
        dgvBanDuocTheoThang.Columns(1).HeaderText = "Số lượng"
        dgvBanDuocTheoThang.Columns(2).HeaderText = "Doanh thu"

        dtgvThongKeNhaCungCap.DataSource = ThongKeDAO.ThongKeNhaCungCap()
        dtgvThongKeNhaCungCap.Columns(0).HeaderText = "Nhà Cung Cấp"
        dtgvThongKeNhaCungCap.Columns(1).HeaderText = "Doanh Thu"
        dtgvThongKeNhaCungCap.Columns(2).HeaderText = "Số Lượng Sản Phẩm"
        dtgvThongKeNhaCungCap.Columns(2).Width = 200

        dtgvHetHang.DataSource = ThongKeDAO.HetHang()
        dtgvHetHang.Columns(0).HeaderText = "Tên hàng"
        dtgvHetHang.Columns(1).HeaderText = "Số lượng"
    End Sub

    Private Sub btnTien_Click(sender As System.Object, e As System.EventArgs) Handles btnTien.Click
        _ThongKe.Nam = _ThongKe.Nam + 1
        lbNam.Text = _ThongKe.Nam.ToString()
        ThongKe(_ThongKe)
    End Sub

    Private Sub btnLui_Click(sender As System.Object, e As System.EventArgs) Handles btnLui.Click
        _ThongKe.Nam = _ThongKe.Nam - 1
        lbNam.Text = _ThongKe.Nam.ToString()
        ThongKe(_ThongKe)
    End Sub

    Private Sub btnLuiThang_Click(sender As System.Object, e As System.EventArgs) Handles btnLuiThang.Click
        _ThongKe.Thang = _ThongKe.Thang - 1
        If _ThongKe.Thang < 1 Then
            _ThongKe.Thang = 12
        End If
        lbThang.Text = _ThongKe.Thang.ToString()
        ThongKe(_ThongKe)
    End Sub

    Private Sub btnTienThang_Click(sender As System.Object, e As System.EventArgs) Handles btnTienThang.Click
        _ThongKe.Thang = _ThongKe.Thang + 1
        If _ThongKe.Thang > 12 Then
            _ThongKe.Thang = 1
        End If
        lbThang.Text = _ThongKe.Thang.ToString()
        ThongKe(_ThongKe)
    End Sub

    Sub ThongKe(ByVal _ThongKe As ThongKe)
        dgvBanDuocTheoThang.DataSource = ThongKeDAO.ThongKeSoLuong(_ThongKe)
        lbNam.Text = _ThongKe.Nam.ToString()
        lbThang.Text = _ThongKe.Thang.ToString()
    End Sub
End Class